package com.javafx.application;

import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
import javafx.application.Application;
import javafx.embed.swing.SwingNode;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 * 建立一个简单的JGgphX
 */
public class Main1 extends Application {


    public void start(Stage stage) throws Exception {

        mxGraph graph = new mxGraph();
        Object parent = graph.getDefaultParent();

        graph.getModel().beginUpdate();

        try{
            Object v1 = graph.insertVertex(parent, null, "Hello", 30, 30, 100, 100);
            Object v2 = graph.insertVertex(parent, null, "world", 240, 300, 100, 100);

        }finally {
            graph.getModel().endUpdate();
        }

        mxGraphComponent componet = new mxGraphComponent(graph);
        componet.setDragEnabled(false);
        SwingNode node = new SwingNode();
        node.setContent(componet);

        StackPane root = new StackPane();
        Scene scene = new Scene(root,500,500);
        root.getChildren().add(node);

        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
